import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

/*const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
  'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='*/
const publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCIl765s5O5gkJy+JKScjHOuyD4\n" +
  "/RLZIwTvSYIP4C2WZHewe7FEDWsY9/b19IbYhsZjycuGgGsf/VplKaWxnGC/WXZC\n" +
  "sMPWpW96V+4vH3DqdIoYWPPbN5QyH0Yvh+W+W9AJChsthC35KGBcU6T/LbvCwkSi\n" +
  "HXfoC7wV5I8dbh+5VQIDAQAB"

/*const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
  '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
  'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
  'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
  'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
  'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
  'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
  'UP8iWi1Qw0Y='*/
const privateKey = "MIICXQIBAAKBgQCIl765s5O5gkJy+JKScjHOuyD4/RLZIwTvSYIP4C2WZHewe7FE\n" +
  "DWsY9/b19IbYhsZjycuGgGsf/VplKaWxnGC/WXZCsMPWpW96V+4vH3DqdIoYWPPb\n" +
  "N5QyH0Yvh+W+W9AJChsthC35KGBcU6T/LbvCwkSiHXfoC7wV5I8dbh+5VQIDAQAB\n" +
  "AoGAGFEDWCXa75R75eHQnheMPGRd21WaTGOKllq8t7zOAM8D67wpc5b78Ob75Q9S\n" +
  "Div4F32uKNSlvX0p4YaHg9X19vabbh1Unf/rEqAen3Q33YoOAWIDjMiEcjNN4PTH\n" +
  "Q78VZ5HRg+ZBtmUJr4X1aZdP5otvvkVIXPpgl/uOn45c/SECQQDmUKJZfggLLPAY\n" +
  "UpK8NGsO3vJXgmKXXF+kxGN1DK4UdDasgbNBfwpI7mfhh9xwXBlR6o1vMLntrLnX\n" +
  "A4GY4VotAkEAl9NkmPOgSu/qZSVDjAq3TsVWf18FsOOdNVJJWW5kEYf0hlgpaIrN\n" +
  "SOXRyOsu4T0KSNPd2LjsRkR+6nJI738cyQJBANINOnQ6QKXIn1TfglpJyFYwuX9c\n" +
  "OATpx4UjY73uCZo3/2FHjTAv6DZp0K5dVYvYQ3N1YvbEzt3YiUlzNjAzXyUCQEhI\n" +
  "quJvS2eiJfSV8zzfdTqZlX763JjFJXnXfXiIqDf4hKDZpI1TWD1WvbRs1FsEVrsp\n" +
  "s7uU/1jND6fLVZJA8JECQQDDq+MA5CmOTRj7yA1hLqAOxJyOmK6N551TCWhOT1FA\n" +
  "ZrEcpxfNnoQOK/2XhVqOI2x+GrJtNAS5ghz6xUdcdb5h"

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

